package com.kefu.chat.vo;

import cn.hutool.core.collection.CollUtil;
import com.google.common.collect.Lists;
import com.kefu.chat.model.ChatSessionTagRel;
import com.kefu.common.context.KefuContext;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

@Data
@ApiModel
public class ChatSessionTagRelInsertVo {
    @NotEmpty
    @ApiModelProperty(name = "sessionId", value = "会话id")
    private String sessionId;

    @NotNull
    @ApiModelProperty(name = "basicTags", value = "标签列表")
    private List<String> basicTags;

    public List<ChatSessionTagRel> tagConvert(String sessionId) {
        List<ChatSessionTagRel> list = Lists.newArrayList();
        if (CollUtil.isNotEmpty(basicTags)) {
            for (String tag : basicTags) {
                ChatSessionTagRel ch = new ChatSessionTagRel();
                ch.setSessionId(sessionId);
                ch.setTagId(tag);
                ch.setCreateUser(KefuContext.getUid());
                ch.setCreateTime(KefuContext.getKefuContext().getNow());
                list.add(ch);
            }
        }
        return list;
    }
}
